begintownscript;
variables;
int choice, text_bubble;
int flag = 0;
int fx = 0, fy = 0;
body;

beginstate 0;
     if ((get_current_tick() < 625) || (get_current_tick() > 4375) &&
         (get_current_tick() < 5000 + 625) || (get_current_tick() > 5000 + 4375) &&
         (get_current_tick() < 10000 + 625) || (get_current_tick() > 10000 + 4375) &&
         (get_current_tick() < 15000 + 625) || (get_current_tick() > 15000 + 4375) &&
         (get_current_tick() < 20000 + 625) || (get_current_tick() > 20000 + 4375) &&
         (get_current_tick() < 25000 + 625) || (get_current_tick() > 25000 + 4375))
         set_state_continue(50);
         if (get_flag(1, 1) == 0) {
              set_terrain(14, 23, 301);
              }
         set_name(6, "Archie");
         set_name(10, "Hamer");
         set_name(12, "Sorsha");
         set_char_dialogue_pic(12, 1921, 0);
         set_char_dialogue_pic(6, 1955, 0);
break;
beginstate 1;
break;
beginstate 2;
       if ((get_current_tick() < 625) || (get_current_tick() > 4375) &&
         (get_current_tick() < 5000 + 625) || (get_current_tick() > 5000 + 4375) &&
         (get_current_tick() < 10000 + 625) || (get_current_tick() > 10000 + 4375) &&
         (get_current_tick() < 15000 + 625) || (get_current_tick() > 15000 + 4375) &&
         (get_current_tick() < 20000 + 625) || (get_current_tick() > 20000 + 4375) &&
         (get_current_tick() < 25000 + 625) || (get_current_tick() > 25000 + 4375))
         set_state_continue(50);
       text_bubble = get_ran(1, 1, 3);
       if (text_bubble == 1) // Sorsha's talk
              text_bubble_on_char(12, "Watchoo.");
       if (text_bubble == 2)
              text_bubble_on_char(12, "Snif.");
       if (text_bubble == 3)
              text_bubble_on_char(12, "");
              
              
              
       text_bubble = get_ran(1, 1, 3); // Archie's talk
       if (text_bubble == 1)
              text_bubble_on_char(6, "I have no boats.");
       if (text_bubble == 2)
              text_bubble_on_char(6, "Not yet.");
       if (text_bubble == 3)
              text_bubble_on_char(6, "");
              
       
              
       text_bubble = get_ran(1, 1, 3); // Hamer's talk
       if (text_bubble == 1)
              text_bubble_on_char(10, "Uff.");
       if (text_bubble == 2)
              text_bubble_on_char(10, "I'm leaving.");
       if (text_bubble == 3)
              text_bubble_on_char(10, "");
             
             
       
       text_bubble = get_ran(1, 1, 3); // Archie's Workers
       if (text_bubble == 1)
              text_bubble_on_char(7, "Dum-di-dum.");
              text_bubble_on_char(8, "Uh.");
       if (text_bubble == 2)
              text_bubble_on_char(7, "Hum-di-hum.");
              text_bubble_on_char(8, "Hmmm.");
       if (text_bubble == 3)
              text_bubble_on_char(7, "");
              text_bubble_on_char(8, "");
       
       
       
       text_bubble = get_ran(1, 1, 3); // Guards
       if (text_bubble == 1)
              text_bubble_on_char(11, "Hahaha.");
              text_bubble_on_char(13, "Argh.");
       if (text_bubble == 2)
              text_bubble_on_char(11, "Hmmm.");
              text_bubble_on_char(13, "Nihihi.");
       if (text_bubble == 3)
              text_bubble_on_char(11, "");
              text_bubble_on_char(13, "");
break;
beginstate 10;
       reset_dialog();
       add_dialog_str(0, "You stand on the dock. If you were going to sail back to Valorim, this is the only available place. There are no ships currently, but if you'd wait a while, maybe you could hitch-hike on one.", 0);
       add_dialog_str(1, "Do you wish to leave this scenario?", 0);
       add_dialog_choice(0, "No");
       add_dialog_choice(1, "Yes");
       choice = run_dialog(1);
       if (choice == 2) {
              if (get_flag(8, 8) == 2)
              {
                  message_dialog("You did what you were told to, and you got your reward. Now you are free to go home.", "THE END");
                  end_scenario(1);
              }
              message_dialog("It doesn't take long before a ship arrives here. While the sailors are loading the ship, you sneak in. Sometimes the foe is just too cunning and strong and, like now, fleeing is the best choice.", "Now you can only hope that somebody else will do the Serpent Salvation. THE END");
              end_scenario(0);
              }
break;
beginstate 11;
     pause(1);
break;
beginstate 50;
       while (fy < 48)
         {
         if (get_terrain(fx, fy) == 480)
             set_terrain(fx, fy, 209);
         fx = fx + 1;
         if (fx == 48)
             {
             fx = 0;
             fy = fy + 1;
             }
         }
break;